package com.ruoyi.teacherCourse.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.teacherCourse.domain.TeacherCourse;
import com.ruoyi.teacherCourse.service.ITeacherCourseService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * teacherCourseController
 * 
 * @author dlh
 * @date 2024-12-05
 */
@RestController
@RequestMapping("/teacherCourse/teacherCourse")
public class TeacherCourseController extends BaseController
{
    @Autowired
    private ITeacherCourseService teacherCourseService;

    /**
     * 查询teacherCourse列表
     */
    @PreAuthorize("@ss.hasPermi('teacherCourse:teacherCourse:list')")
    @GetMapping("/list")
    public TableDataInfo list(TeacherCourse teacherCourse)
    {
        startPage();
        List<TeacherCourse> list = teacherCourseService.selectTeacherCourseList(teacherCourse);
        return getDataTable(list);
    }

    /**
     * 导出teacherCourse列表
     */
    @PreAuthorize("@ss.hasPermi('teacherCourse:teacherCourse:export')")
    @Log(title = "teacherCourse", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TeacherCourse teacherCourse)
    {
        List<TeacherCourse> list = teacherCourseService.selectTeacherCourseList(teacherCourse);
        ExcelUtil<TeacherCourse> util = new ExcelUtil<TeacherCourse>(TeacherCourse.class);
        util.exportExcel(response, list, "teacherCourse数据");
    }

    /**
     * 获取teacherCourse详细信息
     */
    @PreAuthorize("@ss.hasPermi('teacherCourse:teacherCourse:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(teacherCourseService.selectTeacherCourseById(id));
    }

    /**
     * 新增teacherCourse
     */
    @PreAuthorize("@ss.hasPermi('teacherCourse:teacherCourse:add')")
    @Log(title = "teacherCourse", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TeacherCourse teacherCourse)
    {
        return toAjax(teacherCourseService.insertTeacherCourse(teacherCourse));
    }

    /**
     * 修改teacherCourse
     */
    @PreAuthorize("@ss.hasPermi('teacherCourse:teacherCourse:edit')")
    @Log(title = "teacherCourse", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TeacherCourse teacherCourse)
    {
        return toAjax(teacherCourseService.updateTeacherCourse(teacherCourse));
    }

    /**
     * 删除teacherCourse
     */
    @PreAuthorize("@ss.hasPermi('teacherCourse:teacherCourse:remove')")
    @Log(title = "teacherCourse", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(teacherCourseService.deleteTeacherCourseByIds(ids));
    }
}
